const children = [
    {
        path: '/information/user',
        name: 'informationuser',
        component: () => import('@/views/information/user/user.vue')
    },
    {
        path: '/information/classroom',
        name: 'informationclassroom',
        component: () => import('@/views/information/classroom/classroom.vue')
    },
    {
        path: '/classroom/current',
        name: 'classroomcurrent',
        component: () => import('@/views/classroom/current/current.vue')
    },
    {
        path: '/classroom/query',
        name: 'classroomquery',
        component: () => import('@/views/classroom/query/query.vue')
    },
    {
        path: '/classroom/recommend',
        name: 'classroomrecommend',
        component: () => import('@/views/classroom/recommend/recommend.vue')
    },
    {
        path: '/classroom/feedback',
        name: 'classroomfeedback',
        component: () => import('@/views/classroom/feedback/feedback.vue')
    },
];
const routes = [

    //访问路由“/”,自动重定向到"/home"
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login.vue')
    },
    {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/home/home.vue'),
        children
    },
    {
        path: '/404',
        name: "NotFound",
        component: () => import('@/views/404.vue')
    }

];

export const existsRoute = (path) => {
    for (let i = 0; i < routes.length; i++) {
        const r = routes[i];
        if (r.path == path) {
            return true;
        }
        if (r.children && r.children.length) {
            for (let k = 0; k < r.children.length; k++) {
                const sr = r.children[k];
                if (sr.path == path) {
                    return true;
                }
            }
        }
    }
    return false;
};

export default routes;